package org.bluedream.core.module.dao.bill.ord;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.bluedream.core.module.entity.bill.ord.Ord;

import java.io.Serializable;

/**
 * @ClassName OrdDao
 * @Description TODO
 * @Author foxsand
 * @Data 14:39
 * @Version
 */
public interface OrdDao extends BaseMapper<Ord> {
    @Override
    @Select("select Ord.bill_type as billType , Ord.bill_num as billNum , Ord.filDate as fildate , Ord.dead_date as deadDate , Ord.check_date as checkDate , Ord.check_by as checkBy , " +
            "Ord.war_code as warCode , c.name as warName , " +
            "Ord.supplier_code as supplierCode , b.name as supplierName , Ord.qty as qty , Ord.total as total , " +
            " Ord.id as id , Ord.create_by as createBy , Ord.create_date as createDate , Ord.update_by as updateBy , Ord.update_date as updateDate , Ord.status as status , Ord.remarks as remarks" +
            " from Ord Ord, tSupplier b , warehouse c " +
            "${ew.customSqlSegment} and Ord.supplier_code = b.code and Ord.war_code = c.code")
    IPage<Ord> selectPage(IPage<Ord> page, @Param("ew") Wrapper<Ord> queryWrapper);

    @Override
    @Select("select ord.bill_type as billType , ord.bill_num as billNum , ord.filDate as fildate , ord.dead_date as deadDate , ord.check_date as checkDate , ord.check_by as checkBy , " +
            "ord.war_code as warCode , wareHouse.name as warName , " +
            "ord.supplier_code as supplierCode , supplier.name as supplierName , ord.qty as qty , ord.total as total , " +
            " ord.id as id , ord.create_by as createBy , ord.create_date as createDate , ord.update_by as updateBy , ord.update_date as updateDate , ord.status as status , ord.remarks as remarks , " +
            " supplier.id as \"supplier.id\" , supplier.code as \"supplier.code\" , supplier.name as \"supplier.name\" , " +
            " wareHouse.id as \"wareHouse.id\" , wareHouse.code as \"wareHouse.code\" , wareHouse.name as \"wareHouse.name\"" +
            " from Ord ord, tSupplier supplier , warehouse wareHouse " +
            "where ord.id = #{id} and ord.supplier_code = supplier.code and ord.war_code = wareHouse.code")
    Ord selectById(Serializable id);
}
